.class public Lrexsee/multimedia/RexseeAudioRecorder;
.super Ljava/lang/Object;
.source "RexseeAudioRecorder.java"

# interfaces
.implements Lrexsee/core/browser/clazz/JavascriptInterface;


# static fields
.field public static final EVENT_ONRECORDAUDIOFAILED:Ljava/lang/String; = "onRecordAudioFailed"

.field public static final EVENT_ONRECORDAUDIOSUCCESSED:Ljava/lang/String; = "onRecordAudioSuccessed"

.field private static final INTERFACE_NAME:Ljava/lang/String; = "AudioRecorder"

.field public static final URI_MEDIA_AUDIO:Ljava/lang/String; = "content://media/external/audio/media"


# instance fields
.field private final mBrowser:Lrexsee/core/browser/Browser;

.field private mediaFile:Ljava/lang/String;


# direct methods
.method public constructor <init>(Lrexsee/core/browser/Browser;)V
    .locals 4
    .param p1, "browser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 42
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 38
    const/4 v0, 0x0

    iput-object v0, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mediaFile:Ljava/lang/String;

    .line 44
    iput-object p1, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    .line 45
    iget-object v0, p1, Lrexsee/core/browser/Browser;->eventList:Lrexsee/core/browser/clazz/EventList;

    const-string v1, "onRecordAudioSuccessed"

    invoke-virtual {v0, v1}, Lrexsee/core/browser/clazz/EventList;->add(Ljava/lang/String;)V

    .line 46
    iget-object v0, p1, Lrexsee/core/browser/Browser;->eventList:Lrexsee/core/browser/clazz/EventList;

    const-string v1, "onRecordAudioFailed"

    invoke-virtual {v0, v1}, Lrexsee/core/browser/clazz/EventList;->add(Ljava/lang/String;)V

    .line 48
    iget-object v0, p1, Lrexsee/core/browser/Browser;->urlListeners:Lrexsee/core/browser/RexseeUrl;

    new-instance v1, Lrexsee/multimedia/RexseeAudioRecorder$1;

    new-instance v2, Ljava/lang/StringBuilder;

    iget-object v3, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v3, v3, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v3, v3, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v3, v3, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, ":audio"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, p0, v2}, Lrexsee/multimedia/RexseeAudioRecorder$1;-><init>(Lrexsee/multimedia/RexseeAudioRecorder;Ljava/lang/String;)V

    invoke-virtual {v0, v1}, Lrexsee/core/browser/RexseeUrl;->add(Lrexsee/core/browser/clazz/UrlListener;)V

    .line 82
    return-void
.end method

.method static synthetic access$0(Lrexsee/multimedia/RexseeAudioRecorder;)Lrexsee/core/browser/Browser;
    .locals 1

    .prologue
    .line 40
    iget-object v0, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    return-object v0
.end method

.method static synthetic access$1(Lrexsee/multimedia/RexseeAudioRecorder;Ljava/lang/String;)V
    .locals 0

    .prologue
    .line 38
    iput-object p1, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mediaFile:Ljava/lang/String;

    return-void
.end method

.method static synthetic access$2(Lrexsee/multimedia/RexseeAudioRecorder;)Ljava/lang/String;
    .locals 1

    .prologue
    .line 38
    iget-object v0, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mediaFile:Ljava/lang/String;

    return-object v0
.end method


# virtual methods
.method public getInheritInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 0
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 26
    return-object p0
.end method

.method public getInterfaceName()Ljava/lang/String;
    .locals 2

    .prologue
    .line 22
    new-instance v0, Ljava/lang/StringBuilder;

    iget-object v1, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v1, v1, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v1, v1, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v1, "AudioRecorder"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getLastMediaAudio()Ljava/lang/String;
    .locals 9

    .prologue
    const/4 v3, 0x0

    const/4 v8, 0x0

    .line 85
    iget-object v1, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {v1}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v1

    invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v0

    .line 86
    .local v0, "contentResolver":Landroid/content/ContentResolver;
    const-string v1, "content://media/external/audio/media"

    invoke-static {v1}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/String;

    const-string v4, "_data"

    aput-object v4, v2, v8

    const-string v5, "_id desc"

    move-object v4, v3

    invoke-virtual/range {v0 .. v5}, Landroid/content/ContentResolver;->query(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v6

    .line 87
    .local v6, "cursor":Landroid/database/Cursor;
    if-eqz v6, :cond_0

    invoke-interface {v6}, Landroid/database/Cursor;->getCount()I

    move-result v1

    if-nez v1, :cond_1

    :cond_0
    const-string v1, ""

    .line 91
    :goto_0
    return-object v1

    .line 88
    :cond_1
    invoke-interface {v6}, Landroid/database/Cursor;->moveToFirst()Z

    .line 89
    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, "file://"

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-interface {v6, v8}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    .line 90
    .local v7, "rtn":Ljava/lang/String;
    invoke-interface {v6}, Landroid/database/Cursor;->close()V

    move-object v1, v7

    .line 91
    goto :goto_0
.end method

.method public getNewInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 1
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 30
    new-instance v0, Lrexsee/multimedia/RexseeAudioRecorder;

    invoke-direct {v0, p1}, Lrexsee/multimedia/RexseeAudioRecorder;-><init>(Lrexsee/core/browser/Browser;)V

    return-object v0
.end method

.method public prepareUpload()V
    .locals 4

    .prologue
    .line 115
    iget-object v1, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mediaFile:Ljava/lang/String;

    if-nez v1, :cond_0

    .line 116
    iget-object v1, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/multimedia/RexseeAudioRecorder;->getInterfaceName()Ljava/lang/String;

    move-result-object v2

    const-string v3, "Audio is not ready."

    invoke-virtual {v1, v2, v3}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    .line 125
    :goto_0
    return-void

    .line 118
    :cond_0
    iget-object v1, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->interfaceList:Lrexsee/core/browser/clazz/JavascriptInterfaceList;

    new-instance v2, Ljava/lang/StringBuilder;

    iget-object v3, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v3, v3, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v3, v3, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v3, v3, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "Upload"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Lrexsee/core/browser/clazz/JavascriptInterfaceList;->get(Ljava/lang/String;)Lrexsee/core/browser/clazz/JavascriptInterface;

    move-result-object v0

    check-cast v0, Lrexsee/core/transportation/RexseeUpload;

    .line 119
    .local v0, "uploadObject":Lrexsee/core/transportation/RexseeUpload;
    if-nez v0, :cond_1

    .line 120
    iget-object v1, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/multimedia/RexseeAudioRecorder;->getInterfaceName()Ljava/lang/String;

    move-result-object v2

    const-string v3, "Upload object is not ready."

    invoke-virtual {v1, v2, v3}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_0

    .line 122
    :cond_1
    iget-object v1, v0, Lrexsee/core/transportation/RexseeUpload;->selectedFiles:Ljava/util/ArrayList;

    iget-object v2, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mediaFile:Ljava/lang/String;

    invoke-virtual {v1, v2}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    goto :goto_0
.end method

.method public record()V
    .locals 4

    .prologue
    .line 96
    :try_start_0
    new-instance v1, Landroid/content/Intent;

    const-string v2, "android.provider.MediaStore.RECORD_SOUND"

    invoke-direct {v1, v2}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 97
    .local v1, "intent":Landroid/content/Intent;
    iget-object v2, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v2, v2, Lrexsee/core/browser/Browser;->activityResult:Lrexsee/core/browser/clazz/ActivityResult;

    new-instance v3, Lrexsee/multimedia/RexseeAudioRecorder$2;

    invoke-direct {v3, p0}, Lrexsee/multimedia/RexseeAudioRecorder$2;-><init>(Lrexsee/multimedia/RexseeAudioRecorder;)V

    invoke-virtual {v2, v1, v3}, Lrexsee/core/browser/clazz/ActivityResult;->start(Landroid/content/Intent;Lrexsee/core/browser/clazz/ActivityResult$ActivityResultListener;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 112
    .end local v1    # "intent":Landroid/content/Intent;
    :goto_0
    return-void

    .line 109
    :catch_0
    move-exception v2

    move-object v0, v2

    .line 110
    .local v0, "e":Ljava/lang/Exception;
    iget-object v2, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/multimedia/RexseeAudioRecorder;->getInterfaceName()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3, v0}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/Exception;)V

    goto :goto_0
.end method

.method public upload(Ljava/lang/String;Ljava/lang/String;)V
    .locals 4
    .param p1, "action"    # Ljava/lang/String;
    .param p2, "name"    # Ljava/lang/String;

    .prologue
    .line 128
    iget-object v1, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mediaFile:Ljava/lang/String;

    if-nez v1, :cond_0

    .line 129
    iget-object v1, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/multimedia/RexseeAudioRecorder;->getInterfaceName()Ljava/lang/String;

    move-result-object v2

    const-string v3, "Audio is not ready."

    invoke-virtual {v1, v2, v3}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    .line 140
    :goto_0
    return-void

    .line 131
    :cond_0
    iget-object v1, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->interfaceList:Lrexsee/core/browser/clazz/JavascriptInterfaceList;

    new-instance v2, Ljava/lang/StringBuilder;

    iget-object v3, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v3, v3, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v3, v3, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v3, v3, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "Upload"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Lrexsee/core/browser/clazz/JavascriptInterfaceList;->get(Ljava/lang/String;)Lrexsee/core/browser/clazz/JavascriptInterface;

    move-result-object v0

    check-cast v0, Lrexsee/core/transportation/RexseeUpload;

    .line 132
    .local v0, "uploadObject":Lrexsee/core/transportation/RexseeUpload;
    if-nez v0, :cond_1

    .line 133
    iget-object v1, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/multimedia/RexseeAudioRecorder;->getInterfaceName()Ljava/lang/String;

    move-result-object v2

    const-string v3, "Upload object is not ready."

    invoke-virtual {v1, v2, v3}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_0

    .line 135
    :cond_1
    invoke-virtual {v0}, Lrexsee/core/transportation/RexseeUpload;->clear()V

    .line 136
    iget-object v1, v0, Lrexsee/core/transportation/RexseeUpload;->selectedFiles:Ljava/util/ArrayList;

    iget-object v2, p0, Lrexsee/multimedia/RexseeAudioRecorder;->mediaFile:Ljava/lang/String;

    invoke-virtual {v1, v2}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 137
    invoke-virtual {v0, p1, p2}, Lrexsee/core/transportation/RexseeUpload;->upload(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_0
.end method
